package com.hdaccp.foodsales.controller;

import com.hdaccp.foodsales.dao.jinhuoDao;
import com.hdaccp.foodsales.entity.Jinhuo;
import com.hdaccp.foodsales.entity.Shangpin;
import com.hdaccp.foodsales.service.jinhuoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/jinhuo")
@Scope("prototype")
public class jinhuoController {
@Autowired
   private jinhuoService jinhuoService;
@Autowired
private jinhuoDao jinhuoDao;


    @RequestMapping("/addhuo")
    @ResponseBody
    public int addhuo(Jinhuo jinhuo){ return jinhuoService.addhuo(jinhuo);}

    @RequestMapping("/updata")
    @ResponseBody
    public int updata(Shangpin shangpin){
        return jinhuoService.update(shangpin);
    }
    @RequestMapping("/del")
    @ResponseBody
    public int del(Shangpin shangpin){
        return jinhuoDao.del();
    }


    @RequestMapping("/queryAll")
    @ResponseBody
    public List<Jinhuo> query(HttpServletRequest request){
        List<Jinhuo> list = jinhuoService.queryAll();


        return list;
    }
}
